//
//  KFDDiagramPoint.m
//  
//
//  Created by JIRENTIANXIANG on 6/19/15.
//
//

#import "KFDDiagramPoint.h"

@implementation KFDDiagramPoint

-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    if (self=[super init]) {
        NSString* time=dictionary[@"dateline"];
        self.date=[NSDate dateWithTimeIntervalSince1970:time.floatValue];
        NSString* priceStr=dictionary[@"price"];
        self.price=@(priceStr.floatValue);
        NSString* highPriceStr=dictionary[@"high_price"];
        self.high_price=@(highPriceStr.floatValue);
        NSString* lowPriceStr=dictionary[@"low_price"];
        self.low_price=@(lowPriceStr.floatValue);
        NSString* openPriceStr=dictionary[@"open_price"];
        self.open_price=@(openPriceStr.floatValue);
        NSString* closePriceStr=dictionary[@"close_price"];
        self.close_price=@(closePriceStr.floatValue);
        self.boll=[self numberArrayFromStringArray:dictionary[@"boll"]];
        self.kdj=[self numberArrayFromStringArray:dictionary[@"kdj"]];
        self.ma=[self numberArrayFromStringArray:dictionary[@"ma"]];
        self.macd=[self numberArrayFromStringArray:dictionary[@"macd"]];
    }
    return self;
}

-(NSArray*)numberArrayFromStringArray:(NSArray*)array
{
    NSMutableArray* arr=[NSMutableArray array];
    for (NSString* str in array) {
        NSNumber* num=@(str.floatValue);
        [arr addObject:num];
    }
    return arr;
}

@end
